//#include <exception>
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <iomanip.h>

int rows=3;
int columns=4;
void display(long double **);
void transpose(long double **);
void de_allocate(long double **);

int main(void) {

   randomize();
   long double **data;
   clrscr();
      data = new long double*[rows];        // STEP 1: SET UP THE ROWS.
      for (int j = 0; j < rows; j++)
          data[j] = new long double[columns];  // STEP 2: SET UP THE COLUMNS

   for (int i = 0; i < rows; i++)
      for (int j = 0; j < columns; j++)
          data[i][j] = random(100);            // ARBITRARY INITIALIZATION

   display(data);
   transpose(data);
   de_allocate(data);
   getch();
   return 0;

   }

  void display(long double **data) {
   //clrscr();
   for (int i = 0; i < rows; i++) {
        for (int j = 0; j < columns; j++)
      cout <<setw(7) <<data[i][j]; // *(*(data+i)+j)
    cout <<endl;
       }
   cout<<endl;
   //getch();
   }

  void transpose(long double **data) {
   //clrscr();
   for(int i=0; i< columns; i++)
   {for(int j=0; j< rows; j++)
                   cout << setw(7) << data[j][i];
   cout << endl;}
   //getch();

    }

   void de_allocate(long double **data) {
   //clrscr();
   for (int i = 0; i < rows;  i++)
       delete[] data[i];                 // STEP 1: DELETE THE COLUMNS

   delete[] data;                        // STEP 2: DELETE THE ROWS
   //getch();
   }
